#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 3e5 + 5;

int n, m;
int head[N];
int ver[N << 1], Next[N << 1], tot;
void add(int u, int v) {
  ++tot;
  ver[tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}

vector<int> ch[N];
void dfs(int u, int fu) {
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs(v, u);
    ch[u].push_back(ch[v].size());
  }
}
ll ans = 0;
void dfs2(int u, int fu) {
  if (u != fu) ch[u].push_back(ch[fu].size() - 1);
  sort(ch[u].rbegin(), ch[u].rend());
  int len = ch[u].size();
  rep(i, 0, len - 1) {
    if (!ch[u][i]) break;
    ans = max(ans, 1ll * (i + 1) * ch[u][i] + i + 2);
  }
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs2(v, u);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 2, n) {
    int u, v;
    cin >> u >> v;
    add(u, v), add(v, u);
  }
  dfs(1, 1);
  dfs2(1, 1);
  cout << n - ans;
  return 0;
}